package com.cxf.windex.biz;

import com.cxf.windex.base.biz.BaseBiz;
import com.cxf.windex.entity.BShop;
import com.cxf.windex.entity.TjShop;
import com.cxf.windex.mapper.TjShopMapper;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * 推广店铺
 *
 * @author chenxf
 * @version 1.0
 * @date 2019-01-02 11:04
 **/
@Service
public class TjShopBiz extends BaseBiz<TjShopMapper, TjShop> {
    /**
     * 推广店铺列表
     *
     * @param limit 数量
     * @param offset 页码
     * @param orderStr  排序(升序或者降序)
     * @param openid 推广人Openid
     * @return
     */
    public List<TjShop> list(int limit, int offset, String orderStr, String openid) {
        Example example = new Example(TjShop.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotBlank(openid)) {
            criteria.andEqualTo("openid", openid);
        }
        example.setOrderByClause("crt_time " + orderStr);
        PageHelper.startPage(offset, limit);
        return selectByExample(example);
    }
}
